[% setvar title Allow Calling Any Function With A Syntax Like s/// %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Allow Calling Any Function With A Syntax Like s///</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: John Porter &lt;<a href='mailto:jdporter@min.net'>jdporter@min.net</a>&gt;
  Date: 17 Aug 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 139
  Version: 1
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>The calling syntaces of m()/s() should be consistent with other forms of
function call; this should be achieved not by eliminating the traditional
<code>//</code> form from m()/s(), but by allowing any function to be called with <code>//</code>.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>The strings delimited by the slashes, or other allowed delimiters, would be
passed as the arguments to the function.  Note that this would include a
possible trailing string of <code>\w</code> characters.</p>
<p>Furthermore, if the binding operator is used in conjunction with the function
call, it is passed as the first argument by reference, appropriately arranged.</p>
<p>Some simple example should help to demonstrate the idea:</p>
<pre>	greek( 'alpha', 'beta' );</pre>
<p>could be written as any of the following:</p>
<pre>	greek/alpha/beta/;

	greek#alpha#beta#;

	greek(alpha){beta};</pre>
<p>And, taking advantage of the trailing <code>\w</code> string:</p>
<pre>	greek/alpha/beta;

	greek#alpha#beta;

	greek(alpha)beta;</pre>
<p>Now, the following in the new syntax</p>
<pre>	$foo =~ greek/alpha/beta;</pre>
<p>would be the same as the following in old syntax:</p>
<pre>	greek( \$foo, 'alpha', 'beta' );</pre>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>The mechanism that is currently invoked in the parsing of m()/s() expressions
could be used generally.</p>
<p>Note that all the parameters are necessarily strings; numeric literals
do not get pre-converted by the compiler.  Or rather, whatever perl does
for m()/s() arguments, that would also be done when this syntax is used
to call other functions.</p>
<p>head2 Further Observations</p>
<p>The proposed semantics of the binding operator <code>=~</code> looks to my eye very much
like a method referencing operator for direct (non-blessed) variable objects.</p>
<p>That is, there is no reason to suppose that</p>
<pre>	for ( %db =~ grok/SSN/$ssn/g ) ) { ...</pre>
<p>is not an invocation of the <code>grok</code> &quot;method&quot; on the <code>%db</code> &quot;object&quot;.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p><i><a href='http://search.cpan.org/perldoc?perlop'>perlop</a></i> for details on the calling syntax of m//, s///.</p>
</div>
